﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotNETX.Business.Module
{
    public abstract class BusinessProcessor : IBusinessProcessor
    {
        public BusinessProcessor()
        {
            Modules = new Dictionary<string, IBusinessModule>();
        }

        public abstract void LoadModules();

        public virtual Dictionary<string, IBusinessModule> Modules
        {
            get;
            protected set;
        }

        public virtual string Process(string business, string func, string[] args)
        {
            if (Modules.ContainsKey(business))
            {
                return Modules[business].Invoke(func, args);
            }
            else
            {
                throw new Exception("Invalid business name!");
            }
        }
    }
}
